<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" MaintainScrollPositionOnPostback="true" CodeFile="Questions.aspx.cs" Inherits="Admin_Risk_Questions" Title="APM - Risk Impact Assessment - Questions" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="assessment">
        <ul id="path">
            <li><a href="../../Home.aspx">Home</a> &gt;</li>
            <li>Administration &gt;</li>
            <li><a href="Categories.aspx">Risk Impact Assessment</a> &gt;</li>
            <li>Questions</li>
        </ul>
        <h3 class="questions"><span>Manage Question</span></h3>
        <div id="content">
            <table width="100%" style="border: 15">
                <tr>
                    <td>
                        <asp:Repeater ID="rptCategory" runat="server" OnItemDataBound="rptCategory_ItemDataBound">
                            <HeaderTemplate>
                            </HeaderTemplate>
                            <ItemTemplate>
                            <br />
                                <asp:TextBox ID="txtCatID" Text='<%# Microsoft.Security.Application.AntiXss.HtmlEncode(Eval("QuestionCategoryID").ToString()) %>' runat="server"
                                    ReadOnly="true" Visible="false"></asp:TextBox>
                                <asp:TextBox ID="txtCatName" Text='<%# Microsoft.Security.Application.AntiXss.HtmlEncode(Eval("CategoryName").ToString()) %>' runat="server" ReadOnly="true"
                                    Visible="false"></asp:TextBox>
                                <h4>Category Name: <%# Microsoft.Security.Application.AntiXss.HtmlEncode(Eval("CategoryName").ToString())%></h4><br />
                                <table class="RptItem">
                                    <asp:Repeater ID="rptQuestions" OnItemCommand="rptQuestions_ItemCommand" OnItemDataBound="rptQuestions_ItemDataBound"
                                        runat="server">
                                        <HeaderTemplate>
                                            <tr>
                                                <td>
                                                    <asp:Label Text="Order" ID="lblQSOrderHdr" runat="server"></asp:Label></td>
                                                <td>
                                                    <asp:Label Text="Question" ID="lblQuestHdr" runat="server"></asp:Label></td>
                                                <td>
                                                    <asp:Label Text="Delete" ID="lblDelete" runat="server"></asp:Label></td>
                                            </tr>
                                        </HeaderTemplate>
                                        
                                        <ItemTemplate>
                                            <tr valign="top">
                                                <td>
                                                    <asp:TextBox ID="txtQuestID" runat="server" Font-Names="Tahoma, Verdana, sans-serif"
                                                        ReadOnly="true" Text='<%# Eval("QuestionID") %>' Visible="false"></asp:TextBox>
                                                    <asp:TextBox Width="15" ID="txtSeqOrder" runat="server" Text='<%# Eval("SequenceOrder") %>'
                                                        MaxLength="3" CssClass="input"></asp:TextBox></td>
                                                <asp:RegularExpressionValidator ID="regexQuestOrder" runat="server" ControlToValidate="txtSeqOrder"
                                                    Display="None" ErrorMessage="Invalid Input: Question Order" SetFocusOnError="True"
                                                    ValidationExpression="^[0-9]+$"></asp:RegularExpressionValidator>
                                                <asp:RequiredFieldValidator ID="rfvQuestionOrder" runat="server" ControlToValidate="txtSeqOrder"
                                                    Display="None" ErrorMessage="Required Field: Question Order" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                                <td>
                                                    <asp:TextBox ID="txtQuestionTxt" runat="server" Height="50" MaxLength="1000" onkeypress="verifyMax(this, 1000)"
                                                        onpaste="verifyPaste(this, 1000, 'Question')" ReadOnly="false" Text='<%# Eval("QuestionText") %>'
                                                        TextMode="MultiLine" Visible="true" Width="350"></asp:TextBox>
                                                    <asp:RegularExpressionValidator ID="regexQuestion" runat="server" ControlToValidate="txtQuestionTxt"
                                                        Display="None" ErrorMessage="Invalid Input: Question" SetFocusOnError="True"
                                                        ValidationExpression="<%$ AppSettings:QuestionTxtRegEx %>"></asp:RegularExpressionValidator>
                                                    <asp:RequiredFieldValidator ID="rfvQuestion" runat="server" ControlToValidate="txtQuestionTxt"
                                                        Display="None" ErrorMessage="Required Field: Question" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                                </td>
                                                <td>
                                                    <asp:CheckBox ID="chkDeleteQuest" runat="server" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                </td>
                                                <td>
                                                    <table>
                                                        <asp:Repeater ID="rptAnswers" runat="server" OnItemDataBound="rptAnswers_ItemDataBound"
                                                            OnItemCommand="rptAnswers_ItemCommand">
                                                            <HeaderTemplate>
                                                                <thead>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label Text="Order" ID="lblASOrderHdr" runat="server"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label Text="Answer" ID="lblAnswerHdr" runat="server"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label Text="Weight" ID="lblAnswerWt" runat="server"></asp:Label></td>
                                                                        <td>
                                                                            <asp:Label Text="Delete" ID="lblDelete" runat="server"></asp:Label></td>
                                                                    </tr>
                                                                </thead>
                                                            </HeaderTemplate>
                                                            <ItemTemplate>
                                                                <tr>
                                                                    <td>
                                                                        <asp:TextBox ID="txtAnswerID" Text='<%# Eval("AnswerID") %>' runat="server" ReadOnly="true"
                                                                            Visible="false"></asp:TextBox>
                                                                        <asp:TextBox ID="txtQuestAnsID" Text='<%# Eval("QuestionID") %>' runat="server" ReadOnly="true"
                                                                            Visible="false"></asp:TextBox>
                                                                        <asp:TextBox CssClass="input" Width="15" ID="txtOrder" Text='<%# Eval("AnswerOrder") %>' MaxLength="3" runat="server"></asp:TextBox></td>
                                                                    <asp:RegularExpressionValidator ID="regexAnswerOrder" runat="server" ControlToValidate="txtOrder"
                                                                        Display="None" ErrorMessage="Invalid Input: Answer Order" SetFocusOnError="True"
                                                                        ValidationExpression="^[0-9]+$"></asp:RegularExpressionValidator>
                                                                    <asp:RequiredFieldValidator ID="reqAnswerOrder" runat="server" ControlToValidate="txtOrder"
                                                                        ErrorMessage="Required Field: Answer Order" Display="None" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                                                    <td>
                                                                        <asp:TextBox ID="txtAnswerText" CssClass="input" runat="server" MaxLength="50" onkeypress="verifyMax(this, 50)"
                                                                            onpaste="verifyPaste(this, 50, 'Answer')" ReadOnly="false" Text='<%# Eval("AnswerText") %>'
                                                                            Visible="true"></asp:TextBox></td>
                                                                    <asp:RequiredFieldValidator ID="reqAnswer" runat="server" ControlToValidate="txtAnswerText"
                                                                        ErrorMessage="Required Field: Answer" Display="None" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                                                    <asp:RegularExpressionValidator ID="regexAnswer" runat="server" ControlToValidate="txtAnswerText"
                                                                        Display="None" ErrorMessage="Invalid Input: Answer" SetFocusOnError="True" ValidationExpression="<%$ AppSettings:AnswerTextRegEx %>"></asp:RegularExpressionValidator>
                                                                    <td>
                                                                        <asp:TextBox Width="30" ID="txtAnswerWt" Text='<%# Eval("AnswerWt") %>' runat="server"
                                                                            MaxLength="4" CssClass="input"></asp:TextBox></td>
                                                                    <asp:RequiredFieldValidator ID="reqAnswerWt" runat="server" ControlToValidate="txtAnswerWt"
                                                                        ErrorMessage="Required Field: Answer Weight" Display="None" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                                                    <asp:RegularExpressionValidator ID="regexAnswerWt" runat="server" ControlToValidate="txtAnswerWt"
                                                                        Display="None" ErrorMessage="Invalid Input: Answer Weight" SetFocusOnError="True"
                                                                        ValidationExpression="^[0-9]+$"></asp:RegularExpressionValidator>
                                                                    <td>
                                                                        <asp:CheckBox ID="chkDelete" runat="server" />
                                                                    </td>
                                                                </tr>
                                                            </ItemTemplate>
                                                            <FooterTemplate>
                                                                <tr>
                                                                    <td colspan="3">
                                                                        <asp:Button ID="btnAnsAdd" CommandName="AddAns" Text="Add New Answer" runat="server" /></td>
                                                                </tr>
                                                            </FooterTemplate>
                                                        </asp:Repeater>
                                                    </table>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <tr>
                                                <td colspan="2">
                                                    <asp:Button ID="btnQuestAdd" Text="Add New Question" CommandName="AddQuest" CommandArgument=""
                                                        runat="server" />
                                                    <br />
                                                    <br />
                                                </td>
                                            </tr>
                                        </FooterTemplate>
                                    </asp:Repeater>
                                </table>
                            </ItemTemplate>
                            <SeparatorTemplate>
                                <br />
                                <br />
                            </SeparatorTemplate>
                            <FooterTemplate>
                                <asp:ValidationSummary ID="vsQuestions" runat="server" HeaderText="Please correct the following:"
                                    ShowMessageBox="true" ShowSummary="false" DisplayMode="BulletList" />
                                <asp:Button ID="btnSubmit" CausesValidation="true" CommandName="submit" CommandArgument=""
                                    runat="server" Text="Submit" />
                                <asp:Button ID="btnDelete" runat="server" CausesValidation="false" CommandArgument="Delete"
                                    CommandName="Delete" OnClientClick="return Confirm('Are you sure you want to delete the selected items?');"
                                    OnCommand="DeleteBtn_Click" Text="Delete" UseSubmitBehavior="true" />
                                    <asp:Button ID="btnCancel" CausesValidation="false" OnCommand="CancelBtn_Click" runat="server" Text="Cancel" />
                                    </td>
                            </FooterTemplate>
                        </asp:Repeater>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</asp:Content>
